package common;

/**
 * @author jack
 *
 *	class that contains consts for the application
 */
public class Consts {
	public static final int BatchMaxSize = 10000;
	public static final String insertFormat = 
		"INSERT INTO %s_temp(%s, %s) VALUES(?,?)";
	
	public static final String deleteTempFormat =
		"DELETE FROM %s_temp;";
	
	public static final String insertJoinFromat =
		"INSERT INTO %s " + 
			"SELECT DISTINCT %s_temp.* " + 
			"FROM %s_temp LEFT JOIN %s " +  
			"USING (%s) " + 
			"WHERE %s.%s IS NULL;";

	// use insert select syntax to insert more than 1 record if needed
	public static final String insertManyToManyFormat = 
		"INSERT INTO %s_temp (character_id, %s) SELECT ?,%s FROM %s WHERE %s = ?";
	
	public static final String insertJoinManyFromat =
		"INSERT INTO %s " + 
			"SELECT DISTINCT %s_temp.* " + 
			"FROM %s_temp LEFT JOIN %s " +  
			"USING (character_id, %s) " + 
			"WHERE %s.character_id IS NULL OR %s.%s IS NULL;";
	
	// as we saw the gender relation is 1:N, but to make sure that we get only valid records we added limit 1 to the gender query
	public static final String insertCharacterSql = 
		"INSERT INTO characters_temp (id, name, height, weight, gender) VALUES(?,?,?,?,(Select gender_id from gender where gender = ? LIMIT 1))";
	
}
